﻿#region Copyright(c) 2006 ZO, All right reserved.
// -----------------------------------------------------------------------------
// Copyright(c) 2006 ZO, All right reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   1.  Redistribution of source code must retain the above copyright notice,
//       this list of conditions and the following disclaimer.
//   2.  Redistribution in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//   3.  The name of the author may not be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
#endregion


#region Using directives
using System;
using System.Drawing;
#endregion

namespace ZO.SmartCore.Configuration
{
    /// <summary>
    /// Base Configuration Interface
    /// </summary>
    public interface IConfiguration
    {
        #region Events

        #endregion

        #region Properties

        #endregion

        #region Methods
        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns an empty string value.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested string value or an empty string if not found.</returns>
        string Read(string key);

        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The string value to return if the section or key is not found.</param>
        /// <returns>The requested string value or defaultValue if not found.</returns>
        string Read(string key, string defaultValue);

        /// <summary>
        /// Writes a string value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The string value to write.</param>
        void Write(string key, string value);


        /// <summary>
        /// Reads a Boolean value from the Configuration. If the section or key was not found,
        /// this method returns a Boolean value of false.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested Boolean value or false if not found.</returns>
        bool ReadBoolean(string key);

        /// <summary>
        /// Reads a Boolean value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The Boolean value to return if the section or key is not found.</param>
        /// <returns>The requested Boolean value or or defaultValue if not found.</returns>
        bool ReadBoolean(string key, bool defaultValue);

        /// <summary>
        /// Reads a char value from the Configuration. If the section or key was not found,
        /// this method returns an null char value.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested char value or an empty string if not found.</returns>
        char ReadChar(string key);

        /// <summary>
        /// Reads a char value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The char value to return if the section or key is not found.</param>
        /// <returns>The requested char value or defaultValue if not found.</returns>
        char ReadChar(string key, char defaultValue);

        /// <summary>
        /// Reads a Color value from the Configuration. If the section or key was not found,
        /// this method returns a value of zero.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested Color value or Color.Empty if not found.</returns>
        Color ReadColor(string key);

        /// <summary>
        /// Reads a Color value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The Color value to return if the section or key is not found.</param>
        /// <returns>The requested Color value or aDefault if not found.</returns>
        Color ReadColor(string key, Color defaultValue);

        /// <summary>
        /// Reads a DateTime value from the Configuration. If the section or key was not found,
        /// this method returns a the current date and time.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested DateTime value or the current date and time if not found.</returns>
        DateTime ReadDateTime(string key);

        /// <summary>
        /// Reads a DateTime value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The DateTime value to return if the section or key is not found.</param>
        /// <returns>The requested DateTime value or or aDefault if not found.</returns>
        DateTime ReadDateTime(string key, DateTime defaultValue);

        /// <summary>
        /// Reads a Double value from the Configuration. If the section or key was not found,
        /// this method returns a value of zero.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested Double value or zero if not found.</returns>
        double ReadDouble(string key);

        /// <summary>
        /// Reads a Double value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The Double value to return if the section or key is not found.</param>
        /// <returns>The requested Double value or or defaultValue if not found.</returns>
        double ReadDouble(string key, double defaultValue);

        /// <summary>
        /// Reads a enumeration element value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="enumType">The Type of the enumeration to read.</param>
        /// <param name="defaultValue">The default value to return if the section or key is not found.</param>
        /// <returns>The requested value or defaultValue if not found.</returns>
        object ReadEnum(string key, Type enumType, object defaultValue);

        /// <summary>
        /// Reads a Int32 value from the Configuration. If the section or key was not found,
        /// this method returns zero.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested Int32 value or zero if not found.</returns>
        int ReadInt32(string key);

        /// <summary>
        /// Reads a System.Int32 value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The Int32 value to return if the section or key is not found.</param>
        /// <returns>The requested Int32 value or defaultValue if not found.</returns>
        int ReadInt32(string key, int defaultValue);

        /// <summary>
        /// Reads a Single value from the Configuration. If the section or key was not found,
        /// this method returns a value of zero.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested Single value or zero if not found.</returns>
        float ReadSingle(string key);

        /// <summary>
        /// Reads a Single value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The Single value to return if the section or key is not found.</param>
        /// <returns>The requested Single value or or defaultValue if not found.</returns>
        float ReadSingle(string key, float defaultValue);

        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns an empty string value.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <returns>The requested string value or an empty string if not found.</returns>
        string ReadString(string key);

        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns an empty string value.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="encoded">If true, the string value is assumed to be in HTTP encoding and will be decoded.</param>
        /// <returns>The requested string value or an empty string if not found.</returns>
        string ReadString(string key, bool encoded);

        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The string value to return if the section or key is not found.</param>
        /// <returns>The requested string value or defaultValue if not found.</returns>
        string ReadString(string key, string defaultValue);

        /// <summary>
        /// Reads a string value from the Configuration. If the section or key was not found,
        /// this method returns the value passed in defaultValue.
        /// </summary>
        /// <param name="key">The key to read from.</param>
        /// <param name="defaultValue">The string value to return if the section or key is not found.</param>
        /// <param name="encoded">If true, the string value is assumed to be in HTTP encoding and will be decoded.</param>
        /// <returns>The requested string value or defaultValue if not found.</returns>
        string ReadString(string key, string defaultValue, bool encoded);
 

        /// <summary>
        /// Writes a Boolean value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The bool value to write.</param>
        void WriteBoolean(string key, bool value);

        /// <summary>
        /// Writes a char value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The char value to write.</param>
        void WriteChar(string key, char value);

        /// <summary>
        /// Writes a Color value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The Color value to write.</param>
        void WriteColor(string key, Color value);

        /// <summary>
        /// Writes a DateTime value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The DateTime value to write.</param>
        void WriteDateTime(string key, DateTime value);

        /// <summary>
        /// Writes a Double value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The Double value to write.</param>
        void WriteDouble(string key, double value);

        /// <summary>
        /// Writes a enumeration value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The value to write.</param>
        void WriteEnum(string key, object value);

        /// <summary>
        /// Writes a Int32 value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The Int32 value to write.</param>
        void WriteInt32(string key, int value);

        /// <summary>
        /// Writes a Single value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The Single value to write.</param>
        void WriteSingle(string key, float value);

        /// <summary>
        /// Writes a string value to the Configuration.
        /// </summary>
        /// <param name="key">The key to write to.</param>
        /// <param name="value">The string value to write.</param>
        void WriteString(string key, string value);

  

        #endregion
    }
}

